# 导包
import requests
import config


# 创建接口类（模块）
class LoginAPI:
    # 初始化
    def __init__(self):
        self.url_code = config.BASE_URL + "/common/public/verifycode1/{}"
        self.url_phone = config.BASE_URL + "/member/public/sendSms"
        self.url_reg = config.BASE_URL + "/member/public/reg"
        self.url_login = config.BASE_URL + "/member/public/login"

    # 获取图片验证码
    def get_verify_code(self, r):
        return requests.get(url=self.url_code.format(r))

    # 获取短信验证码
    def get_phone_code(self, phone_data, cookies_data):
        return requests.post(url=self.url_phone, data=phone_data, cookies=cookies_data)

    # 注册
    def reg(self, reg_data, cookies_data):
        return requests.post(url=self.url_reg, data=reg_data, cookies=cookies_data)

    # 登录
    def login(self, login_data):
        return requests.post(url=self.url_login, data=login_data)

    # 登录
    def login666(self, session, login_data):
        return session.post(url=self.url_login, data=login_data)

    # 是否登录
    def verify_login(self):
        pass

